﻿<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:controlsPrimitives="clr-namespace:Microsoft.Phone.Controls.Primitives;assembly=Microsoft.Phone.Controls" 
    x:Class="OmnipotentFlashlight.MainPage"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False">
	<phone:PhoneApplicationPage.Resources>
		
		<Style x:Key="MenuButtonStyle" TargetType="Button">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<Canvas Background="#FFE60012" Margin="11,0,-6,18">
							<TextBlock TextWrapping="Wrap" Text="{TemplateBinding Content}" Canvas.Top="137" Width="175" TextAlignment="Center" Canvas.Left="-20"/>
							<Image Height="193" Canvas.Left="-20" Canvas.Top="-20" 
							Source="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}"  Width="219"/>
						</Canvas>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		
		<Style x:Key="MenuLightButtonStyle" TargetType="Button">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<Canvas Background="#FFE60012">
							<TextBlock Canvas.Left="51" TextWrapping="Wrap" Text="{TemplateBinding Content}" Canvas.Top="104" Width="175" TextAlignment="Center" RenderTransformOrigin="0.577,2.6"/>
							<Image 
							Source="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}" Width="408" Height="191" Stretch="Fill"/>
							<TextBlock Canvas.Left="29" TextWrapping="Wrap" Text="{TemplateBinding Content}" Canvas.Top="146"/>
						</Canvas>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		
		
		<Style x:Key="MoreButtonStyle" TargetType="Button">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<Canvas Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
							<Canvas Height="100" Canvas.Left="1" Width="100" Background="#FFE60012">
								<Image Height="100" Width="100"
									Source="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}"
							/>
							</Canvas>
							<TextBlock Canvas.Left="127" TextWrapping="Wrap" Text="{TemplateBinding Content}" Canvas.Top="14" Height="45" Width="211" FontSize="29.333" Foreground="#FF959595"/>
							<TextBlock Canvas.Left="127" TextWrapping="Wrap" Text="{Binding DataContext, RelativeSource={RelativeSource TemplatedParent}}" Canvas.Top="59" Width="277" Height="37" FontSize="16" Foreground="#72959595" />
						</Canvas>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		
		<Style x:Key="AdsStyle" TargetType="Button">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<Grid>
							<Image x:Name="imgAds" Source="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}" Stretch="UniformToFill" Width="{TemplateBinding Width}"/>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>

       
        <DataTemplate x:Key="ListItemHeader">
			  <TextBlock Text="{Binding}" FontSize="25.333" Foreground="#FF535353" />
		</DataTemplate>
		<Style x:Key="PanoramaItemStyle1" TargetType="controls:PanoramaItem">
			<Setter Property="CacheMode" Value="BitmapCache"/>
			<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
			<Setter Property="VerticalContentAlignment" Value="Stretch"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="controls:PanoramaItem">
						<Grid Background="{TemplateBinding Background}" Margin="12,0,0,0">
							<Grid.RowDefinitions>
								<RowDefinition Height="auto"/>
								<RowDefinition Height="*"/>
							</Grid.RowDefinitions>
							<ContentControl x:Name="header" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" FontSize="{StaticResource PhoneFontSizeExtraExtraLarge}" FontFamily="{StaticResource PhoneFontFamilySemiLight}" HorizontalAlignment="Left" Margin="10,-2,0,26" Foreground="#FF959595">
								<ContentControl.RenderTransform>
									<TranslateTransform x:Name="headerTransform"/>
								</ContentControl.RenderTransform>
							</ContentControl>
							<ContentPresenter Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" Grid.Row="1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		
	
		<Style x:Key="PanoramaStyle1" TargetType="controls:Panorama">
			<Setter Property="ItemsPanel">
				<Setter.Value>
					<ItemsPanelTemplate>
						<controlsPrimitives:PanoramaPanel x:Name="panel"/>
					</ItemsPanelTemplate>
				</Setter.Value>
			</Setter>
			<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
			<Setter Property="Background" Value="Transparent"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="controls:Panorama">
						<Grid>
							<Grid.RowDefinitions>
								<RowDefinition Height="auto"/>
								<RowDefinition Height="*"/>
							</Grid.RowDefinitions>
							<controlsPrimitives:PanningBackgroundLayer x:Name="BackgroundLayer" HorizontalAlignment="Left" Grid.RowSpan="2">
								<Border x:Name="background" Background="{TemplateBinding Background}" CacheMode="BitmapCache"/>
							</controlsPrimitives:PanningBackgroundLayer>
							<controlsPrimitives:PanningTitleLayer x:Name="TitleLayer" CacheMode="BitmapCache" ContentTemplate="{TemplateBinding TitleTemplate}" Content="{TemplateBinding Title}" FontSize="187" FontFamily="{StaticResource PhoneFontFamilyLight}" HorizontalAlignment="Left" Margin="0,-76,0,9" Grid.Row="0" Width="1782"/>
							<controlsPrimitives:PanningLayer x:Name="ItemsLayer" HorizontalAlignment="Left" Grid.Row="1">
								<ItemsPresenter x:Name="items"/>
							</controlsPrimitives:PanningLayer>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
			<StackPanel Background="#B2434343"/>
		</ItemsPanelTemplate>
		<ControlTemplate x:Key="ListPickerControlTemplate1" TargetType="toolkit:ListPicker">
			<Grid/>
		</ControlTemplate>
		
		
		<Style TargetType="toolkit:ListPicker">
        <!--<Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/>-->
        <!--<Setter Property="Background" Value="YellowGreen"/>-->
        <Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="Margin" Value="{StaticResource PhoneTouchTargetOverhang}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="toolkit:ListPicker">
                    <StackPanel>
                        <ContentControl   Content="{TemplateBinding Header}"  ContentTemplate="{TemplateBinding HeaderTemplate}"  
                                          Foreground="{StaticResource PhoneSubtleBrush}" FontSize="{StaticResource PhoneFontSizeNormal}" 
                                          HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"  Margin="0 0 0 8"/>
                        <Grid>
                            <!--<Border   x:Name="Border"   Background="Yellow" BorderBrush="{TemplateBinding Background}"  BorderThickness="2">-->
                            <Border   x:Name="Border"  >
                                    <Canvas x:Name="ItemsPresenterHost" MinHeight="46">
                                    <ItemsPresenter x:Name="ItemsPresenter">
                                        <ItemsPresenter.RenderTransform>
                                            <TranslateTransform x:Name="ItemsPresenterTranslateTransform"/>
                                        </ItemsPresenter.RenderTransform>
                                    </ItemsPresenter>
                                </Canvas>
                            </Border>
                            <Popup x:Name="FullModePopup">
                                <!--<Border Background="{StaticResource PhoneChromeBrush}">-->
                                <Border >
                                    <!-- Popup.Child should always be a Border -->
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition/>
                                        </Grid.RowDefinitions>
                                        <ContentControl   Grid.Row="0" Content="{TemplateBinding FullModeHeader}"
                                                          Foreground="{StaticResource PhoneForegroundBrush}" 
                                                          FontFamily="{StaticResource PhoneFontFamilySemiBold}" FontSize="{StaticResource PhoneFontSizeMedium}"   
                                                          HorizontalAlignment="Left"  Margin="24 12 0 0"/>
                                        <ListBox  x:Name="FullModeSelector" Grid.Row="1" 
                                                  FontSize="{TemplateBinding FontSize}"  Margin="{StaticResource PhoneMargin}" Background="#B2434343">
                                            <ListBox.ItemsPanel>
                                                <ItemsPanelTemplate>
                                                    <StackPanel Background="#B2434343"/>
                                                    <!-- Ensures all containers will be available during the Loaded event -->
                                                </ItemsPanelTemplate>
                                            </ListBox.ItemsPanel>
                                        </ListBox>
                                    </Grid>
                                </Border>
                            </Popup>
                        </Grid>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
		
	
	
	<Style TargetType="toolkit:ListPickerItem">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="Padding" Value="8 10"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="toolkit:ListPickerItem">
                    <Grid Background="{TemplateBinding Background}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected">
                            		<Storyboard>
                                		<ColorAnimation Duration="0" To="#FFE60012" Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="ContentContainer" d:IsOptimized="True"/>
                                	</Storyboard>
                            	</VisualState>
                                <VisualState x:Name="Selected">
                                	<Storyboard>
                                		<ColorAnimation Duration="0" To="#FF62E53F" Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="ContentContainer" d:IsOptimized="True"/>
                                	</Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentControl
                            x:Name="ContentContainer" FontSize="24"
                            Content="{TemplateBinding Content}"
                            ContentTemplate="{TemplateBinding ContentTemplate}"
                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                            Margin="{TemplateBinding Padding}" Foreground="#FF1BA1E2"/> <!--Foreground="{TemplateBinding Foreground}"-->
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
	
	
	</phone:PhoneApplicationPage.Resources>

	<phone:PhoneApplicationPage.FontFamily>
		<StaticResource ResourceKey="PhoneFontFamilyNormal"/>
	</phone:PhoneApplicationPage.FontFamily>
	<phone:PhoneApplicationPage.FontSize>
		<StaticResource ResourceKey="PhoneFontSizeNormal"/>
	</phone:PhoneApplicationPage.FontSize>
	<phone:PhoneApplicationPage.Foreground>
		<StaticResource ResourceKey="PhoneForegroundBrush"/>
	</phone:PhoneApplicationPage.Foreground>
	<phone:PhoneApplicationPage.Style>
		<StaticResource ResourceKey="TransitionPageStyle"/>
	</phone:PhoneApplicationPage.Style>

    <!--LayoutRoot 是包含所有页面内容的根网格-->
    <Grid x:Name="LayoutRoot">
    	<Grid.Background>
    		<ImageBrush Stretch="Fill" ImageSource="icon/blackgroung.png"/>
    	</Grid.Background>
 
        <!--Panorama 控件-->
        <controls:Panorama Style="{StaticResource PanoramaStyle1}" >
            <controls:Panorama.Title>
                <StackPanel Orientation="Horizontal" Margin="0,70,0,0">
                	<Rectangle Fill="#FFE60012" Height="37" Stroke="Black" Width="42"/>
					<TextBlock  Foreground="#FF898989" Text="多功能手电筒" FontSize="24" VerticalAlignment="Center" MaxHeight="60"/>
                    <Rectangle Fill="#FFE60012" Height="37" Stroke="Black" Width="1200"/>
                </StackPanel>
            </controls:Panorama.Title>
 
            <!--Panorama 项目一-->
            <controls:PanoramaItem Header="手电筒" Style="{StaticResource PanoramaItemStyle1}">
                <!--具有文字环绕的双线列表-->
                <ListBox Margin="0,0,-12,0">
                	<Grid Height="200" Width="424" Margin="0,5,0,0">
                		<Button 
						Content="LED手电"  Tag="icon/light.png" 
						Height="191" Margin="8,1,8,8"  
						Style="{StaticResource MenuLightButtonStyle}"
						toolkit:TiltEffect.IsTiltEnabled="True" x:Name="Btn_LED" Click="Btn_LED_Click" />
					</Grid>
					
					<Grid Height="192" Width="424" Margin="0,10,0,0">
						<Button HorizontalAlignment="Left" 
						Content="求救信号"  Tag="icon/i_sos.png" 
						Margin="8,0,0,10" Width="191" Height="191" 
						Style="{StaticResource MenuButtonStyle}"
						toolkit:TiltEffect.IsTiltEnabled="True" x:Name="Btn_SOS" Click="Btn_SOS_Click"
						/>
						
                		<Button HorizontalAlignment="Right" 
						Content="屏幕手电"  Tag="icon/i_close.png" 
						Height="191" Width="191" Margin="0,0,13,9"  
						Style="{StaticResource MenuButtonStyle}"
						toolkit:TiltEffect.IsTiltEnabled="True" x:Name="Btn_Screen" Click="Btn_Screen_Click" />
					</Grid>
					
					<Grid Height="200" Width="424" Margin="0">
						<Button HorizontalAlignment="Left" 
						Content="屏幕变色"  Tag="icon/i_screen.png" 
						Margin="8,0,0,10" Width="191" Height="191" 
						Style="{StaticResource MenuButtonStyle}" 
						toolkit:TiltEffect.IsTiltEnabled="True" x:Name="Btn_ScreenChange" Click="Btn_ScreenChange_Click"
						/>
					</Grid>
					
					<Canvas x:Name="canAds" Height="60" Width="419" Margin="0,-27,0,0" Visibility="Collapsed">
						<Button x:Name="BtnAds" Style="{StaticResource AdsStyle}" 
                                toolkit:TiltEffect.IsTiltEnabled="True" Click="BtnAds_Click" Width="419" Height="52"/>
					</Canvas>
                </ListBox>
				
            </controls:PanoramaItem>
 
        	<controls:PanoramaItem Header="设置" Style="{StaticResource PanoramaItemStyle1}">
        		<ListBox Margin="8,0,-12,0">
        			<toolkit:ListPicker Margin="0" Width="333" Header="默认启动功能" x:Name="Pik_Default" SelectionChanged="Pik_Default_SelectionChanged" 
        				  HeaderTemplate="{StaticResource ListItemHeader}" ItemsPanel="{StaticResource ItemsPanelTemplate1}" Foreground="#FF600627">
        				<toolkit:ListPickerItem Content="无" Tag="wu" />
        				<toolkit:ListPickerItem Content="LED手电" Tag="led" />
        				<toolkit:ListPickerItem Content="求救信号" Tag="sos"   />
        				<toolkit:ListPickerItem Content="屏幕手电" Tag="screen" />
        				<toolkit:ListPickerItem Content="屏幕变色" Tag="change" />
        			</toolkit:ListPicker>

        			<toolkit:ListPicker Margin="0,30,0,0" Width="{Binding Width, ElementName=Pik_Default}" x:Name="Pik_ScreenLight" SelectionChanged="ListPicker_SelectionChanged"
        				Header="屏幕手电亮度设置" HeaderTemplate="{StaticResource ListItemHeader}" ItemsPanel="{StaticResource ItemsPanelTemplate1}" Background="{x:Null}">
        				<toolkit:ListPickerItem Content="高亮度" Tag="gao" />
        				<toolkit:ListPickerItem Content="中亮度" Tag="zhong" />
        				<toolkit:ListPickerItem Content="低亮度" Tag="di" />
        			</toolkit:ListPicker>

        			<toolkit:ListPicker Margin="0,30,0,0" Width="{Binding Width, ElementName=Pik_Default}" x:Name="Pik_ScreenShake" SelectionChanged="ListPicker_SelectionChanged_1"
        				Header="屏幕手电晃动变色设置" HeaderTemplate="{StaticResource ListItemHeader}" ItemsPanel="{StaticResource ItemsPanelTemplate1}" Background="{x:Null}">
        				<toolkit:ListPickerItem Content="功能关闭" Tag="0" />
        				<toolkit:ListPickerItem Content="高灵敏度" Tag="1" />
        				<toolkit:ListPickerItem Content="中灵敏度" Tag="2" />
        				<toolkit:ListPickerItem Content="低灵敏度" Tag="3" />
        			</toolkit:ListPicker>

        			<toolkit:ListPicker  Margin="0,30,0,0" Width="{Binding Width, ElementName=Pik_Default}" x:Name="Pik_ChangeMode" SelectionChanged="ListPicker_SelectionChanged_2"
        				Header="变色模式设置" HeaderTemplate="{StaticResource ListItemHeader}" ItemsPanel="{StaticResource ItemsPanelTemplate1}" Background="{x:Null}">
        				<toolkit:ListPickerItem Content="变色模式" Tag="bianse" />
        				<toolkit:ListPickerItem Content="闪烁模式" Tag="shanshuo" />
        				<toolkit:ListPickerItem Content="警灯模式" Tag="jingdeng" />
        				<toolkit:ListPickerItem Content="彩虹模式" Tag="caihong" />
        			</toolkit:ListPicker>
        		</ListBox>
        	</controls:PanoramaItem>

        	<controls:PanoramaItem Header="更多" Style="{StaticResource PanoramaItemStyle1}">
        		<ListBox Margin="0,0,-12,0">
        			<Button Content="精品软件" Tag="icon/j_software.png" DataContext="更多市场中的精品App推荐" x:Name="Btn_Soft" Click="Btn_Soft_Click"
        				Style="{StaticResource MoreButtonStyle}" Visibility="Collapsed"
        				Height="100"  Width="277" toolkit:TiltEffect.IsTiltEnabled="True" Margin="20,0,0,0"/>
					
        			<Button Content="意见反馈" Tag="icon/j_feedback.png" DataContext="你对此软件有任何建议或意见请点此发送给我们" x:Name="Btn_Back" Click="Btn_Back_Click"
        				Style="{StaticResource MoreButtonStyle}"
        				Height="100"  Width="277" Margin="20,25,0,0" toolkit:TiltEffect.IsTiltEnabled="True"/>

        			<Button Content="关于" Tag="icon/j_about.png" DataContext="关于本软件的信息" x:Name="Btn_About" Click="Btn_About_Click"
        				Style="{StaticResource MoreButtonStyle}"
        				Height="100"  Width="277" Margin="20,25,0,0" toolkit:TiltEffect.IsTiltEnabled="True"/>

        		</ListBox>
        	</controls:PanoramaItem>
            
        </controls:Panorama>
    </Grid>
</phone:PhoneApplicationPage>